package com.yoyo.itravel.dao;


import com.yoyo.itravel.bean.Country;
import com.yoyo.itravel.constants.BaseSqlProviderConstant;
import com.yoyo.itravel.sql_provider.BaseSqlProvider;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.List;

/**
 * @Description 国家表相关操作接口【持久层】
 *
 * @author HZX
 * @date 2020/5/8 23:17
 */
@Repository
public interface ICountryDao {

	/**
	 * @Description 得到所有的国家信息
	 *
	 * @param
	 * @return java.util.List<com.yoyo.itravel.bean.Country>
	 */
	// @Select("select * from tb_country")
	@SelectProvider(type = BaseSqlProvider.class, method = BaseSqlProviderConstant.SELETE)
	List<Country> selectAll(Country country) throws SQLException;

	/**
	 * @Description 插入国家信息
	 *
	 * @param country
	 * @return int
	 */
	// @Insert("insert into tb_country(countryId,countryName) values(#{country.countryId},#{country.countryName})")
	@InsertProvider(type = BaseSqlProvider.class, method = BaseSqlProviderConstant.INSERT)
	int insert(Country country) throws SQLException;

	/**
	 * @Description 修改国家信息
	 *
	 * @Param country
	 * @Return int
	 */
	@UpdateProvider(type = BaseSqlProvider.class, method = BaseSqlProviderConstant.UPDATE_BY_ID)
	int update(Country country) throws SQLException;

	/**
	 * @Description 删除国家信息
	 *
	 * @Param country
	 * @Return int
	 */
	@DeleteProvider(type = BaseSqlProvider.class, method = BaseSqlProviderConstant.DELETE_BY_ID)
	int delete(Country country) throws SQLException;

	/**
	 * @Description 通过国家id得到对应的国家信息
	 *
	 * @param countryId
	 * @return com.yoyo.itravel.bean.Country
	 */
	@Select("select * from tb_country where countryId=#{countryId}")
	Country selectByCountryId(String countryId) throws SQLException;

	/**
	 * @Description 通过国家名称得到对应的国家信息
	 *
	 * @param country
	 * @return com.yoyo.itravel.bean.Country
	 */
	// @Select("select * from tb_country where countryName=#{provinceName}")
	@SelectProvider(type = BaseSqlProvider.class, method = BaseSqlProviderConstant.SELETE)
	Country selectByCountryName(Country country) throws SQLException;

}
